package cn.bluethink.eguan.okrtask.entity;

import java.util.Date;

import cn.bluethink.eguan.model.core.EgFaction;
import cn.bluethink.eguan.model.core.EgTavern;
import cn.bluethink.eguan.model.core.EgUser;
import cn.bluethink.eguan.model.okrtask.EgOkrTask;

/**
 * 工作任务实体类 返回联合查询后的数值
 * 
 * @title 苏州中科蓝迪公司所有(c)2016-2021
 * @version 0.1.0
 * @describe
 * @author liuxn
 * @date 2018年10月14日
 */
public class OKRTaskEntity {

    private Long tid;

    private Long otype;

    private String name;

    private String content;

    private String tags;

    private Integer status;

    private Integer priority;

    private Integer cycle;

    /**
     * 任务发布者
     */
    private Long cuid;
    private String cuname;

    /**
     * 驿馆Id和驿馆名称
     */
    private Long egid;
    private String egname;
    private String egicon;

    /**
     * 门派Id
     */
    private Long factionid;
    private String factionname;
    private Integer bmonth;

    /**
     * 任务结果ID和任务结果类型
     */
    /*
     * private Long resulttype; private Long resultoid;
     */

    private Date etime;

    private Date ftime;

    private Integer checkStatus;

    /**
     * 工作任务字段
     */
    private Integer timing;
    private Long douid;
    private String doname;

    private Integer expSkp;
    private Boolean istrain;
    
    private Integer color;

    public OKRTaskEntity() {

    }

    public EgOkrTask createOKRTask() {
        EgOkrTask okrtask = new EgOkrTask(tid, name, content);
        okrtask.setTags(tags);
        okrtask.setStatus(status);
        okrtask.setPriority(priority);

        EgTavern tavern = new EgTavern(egid, egname, egicon);

        if (factionid == null) {
            factionid = 0L;
            factionname = "驿馆江湖";
        }

        EgFaction faction = new EgFaction(factionid, factionname, null);
        tavern.setFaction(faction);
        okrtask.setPos(tavern);

        okrtask.setEtime(etime);
        okrtask.setFtime(ftime);
        okrtask.setCheckStatus(checkStatus);
        okrtask.setTiming(timing);

        if (cuid != null && cuid > 0) {
            EgUser cuser = new EgUser(cuid, cuname, null);
            okrtask.setCuser(cuser);
        } else {
            okrtask.setDouser(new EgUser());
        }

        if (douid != null && douid > 0) {
            EgUser douser = new EgUser(douid, doname, null);
            okrtask.setDouser(douser);
        } else {
            okrtask.setDouser(new EgUser());
        }

        okrtask.setExpSkp(expSkp);
        okrtask.setColor(color);
        // okrtask.setBtrain(istrain);
        okrtask.calculateLabel(bmonth);
        return okrtask;

    }

    /**
     * 转为关联的目标
     * @return
     */
    public EgOkrTask createRelateOkrTask() {
        EgOkrTask target = new EgOkrTask(tid, name, null);
        target.setTiming(timing);
        target.setEtime(etime);
        return target;
    }

    public Long getTid() {
        return tid;
    }

    public void setTid(Long tid) {
        this.tid = tid;
    }

    public Long getOtype() {
        return otype;
    }

    public void setOtype(Long otype) {
        this.otype = otype;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getTags() {
        return tags;
    }

    public void setTags(String tags) {
        this.tags = tags;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public Integer getCycle() {
        return cycle;
    }

    public void setCycle(Integer cycle) {
        this.cycle = cycle;
    }

    public Long getEgid() {
        return egid;
    }

    public void setEgid(Long egid) {
        this.egid = egid;
    }

    public String getEgname() {
        return egname;
    }

    public void setEgname(String egname) {
        this.egname = egname;
    }

    public Date getEtime() {
        return etime;
    }

    public void setEtime(Date etime) {
        this.etime = etime;
    }

    public Date getFtime() {
        return ftime;
    }

    public void setFtime(Date ftime) {
        this.ftime = ftime;
    }

    public Integer getCheckStatus() {
        return checkStatus;
    }

    public void setCheckStatus(Integer checkStatus) {
        this.checkStatus = checkStatus;
    }

    public Integer getExpSkp() {
        return expSkp;
    }

    public void setExpSkp(Integer expSkp) {
        this.expSkp = expSkp;
    }

    public Integer getTiming() {
        return timing;
    }

    public void setTiming(Integer timing) {
        this.timing = timing;
    }

    public Long getDouid() {
        return douid;
    }

    public void setDouid(Long douid) {
        this.douid = douid;
    }

    public String getDoname() {
        return doname;
    }

    public void setDoname(String doname) {
        this.doname = doname;
    }

    public Boolean getIstrain() {
        return istrain;
    }

    public void setIstrain(Boolean istrain) {
        this.istrain = istrain;
    }

    public Long getCuid() {
        return cuid;
    }

    public void setCuid(Long cuid) {
        this.cuid = cuid;
    }

    public String getCuname() {
        return cuname;
    }

    public void setCuname(String cuname) {
        this.cuname = cuname;
    }

    public String getEgicon() {
        return egicon;
    }

    public void setEgicon(String egicon) {
        this.egicon = egicon;
    }

    public Long getFactionid() {
        return factionid;
    }

    public void setFactionid(Long factionid) {
        this.factionid = factionid;
    }

    public String getFactionname() {
        return factionname;
    }

    public void setFactionname(String factionname) {
        this.factionname = factionname;
    }

    public Integer getBmonth() {
        return bmonth;
    }

    public void setBmonth(Integer bmonth) {
        this.bmonth = bmonth;
    }

}
